{SysSrv} = require "./SysSrv"
{EmpAddSrv} = require "./EmpAddSrv"

SupperClzz = SysSrv
exports.Et_pswSrv = new Class
  Extends: SupperClzz
  options:
    tab: "emp"
    $vdts: ["psw"]
  et_psw: (reqOpt,old_psw,psw)->
    t = this
    o = t.options
    emp = t.session.emp
    yield t.runAllVdts reqOpt,{psw:psw}
    rltSet = yield t.callSql reqOpt,"select count(id) count from emp where id=$1 and password=$2",[emp.id,old_psw]
    if rltSet.rows[0].count is 0
      throw "原密码错误,请重新输入!"
    yield t.callSql reqOpt,"update emp set password=$2 where id=$1",[emp.id,psw]
    true
  pswVdt: (reqOpt,key,val)-> yield EmpAddSrv.prototype.passwordVdt.apply this,arguments